package com.xianyun.book.controller;

import com.alibaba.cola.dto.Response;
import com.alibaba.cola.dto.SingleResponse;
import com.xianyun.book.api.PayServiceI;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
import javax.validation.constraints.NotEmpty;
import java.util.Map;

/**
 * @author ytt
 */
@RestController
public class PayController {

    @Autowired
    private PayServiceI payService;

    @GetMapping("/pay/{payId}")
    public Response payMoney(@NotEmpty @PathVariable String payId){
        return payService.payOrderByOrderId(payId);
    }

    @GetMapping("/pay/info/{orderId}")
    public SingleResponse<Map<String,Object>> getPayInfo(@NotEmpty @PathVariable String orderId){
        return payService.getReadyPayInfoByOrderId(orderId);
    }
}
